package com.devicemantra.coordinate.auth;

import java.io.IOException;
import java.util.Date;
import java.util.Iterator;

import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.*;

import org.datanucleus.store.Extent;

import com.devicemantra.coordinate.dataobjects.CLoginInfo;
import com.devicemantra.coordinate.dataobjects.CUserFactory;
import com.devicemantra.coordinate.ds.tests.PMF;

@SuppressWarnings("serial")
public class Login extends HttpServlet 
{
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException 
   {
		String lForwardUrl = null;
		String lLoginName = (String) req.getParameter("login_name");
		String lPassword = (String) req.getParameter("password");
		System.out.println("LoginName is " + lLoginName + " Password is " + lPassword);
		if( lLoginName.equals("SUPER_ADMIN"))
		{
			lForwardUrl = "interface.jsp";
		}
		else
		{
			
			lForwardUrl = "/modules/department/interface.jsp";
			
		}
		
		try {
			req.getSession().setAttribute("user", lLoginName);
			req.getRequestDispatcher(lForwardUrl).forward(req,resp);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
   }
}
